﻿using ProxyViewModel;
using System.ComponentModel;
using ProxyViewModel.Commands;
using System;
using System.Collections.ObjectModel;

namespace AutoViewModel.Tests {
	public class TestClass : IContainedViewModel {
		private object _parentViewModel;
		private bool _isValid = true;
		private string _lastValidationMessage;

		public void SetParentViewModel(object parentViewModel) {
			_parentViewModel = parentViewModel;
		}

		public void Invalidate(string propertyName) {
			if (_parentViewModel != null) {
				ProxyCommandManager.InvalidateRequerySuggested(_parentViewModel);
			}
		}

		public string LastValidationMessage {
			get { return _lastValidationMessage; }
			set {
				if (_lastValidationMessage != value) {
					_lastValidationMessage = value;
					RaisePropertyChanged("LastValidationMessage");
				}
			}
		}

		private void RaisePropertyChanged(string propertyName) {

		}

		public bool IsValid(string propertyName, object inputObject) {
			return ValidationManager.IsValid(GetType(), propertyName, inputObject, this);
		}
	}
}
